// import PeripheralSystemDataMgr from './PeripheralSystemDataMgr';
// import ClientData from './ClientData';
// import SdkHelper from './SdkHelper';
// import EngineUtil from './EngineUtil';
// import PlayerDataSys from './PlayerDataSys';

const { ccclass, property } = cc._decorator;

@ccclass
class SystemDataSys {

    public static _instance: SystemDataSys | null = null;

    static encrypt: number = 0;

    static new_user: boolean = false;

    public server_release_url: string = "";
    public server_test_url: string = "";

    public version_release_url: string = "";
    public version_test_url: string = "";

    public user_url: string = "";
    public privacy_url: string = "";

    public reviewing: boolean = true;
    public reviewing_splash: boolean = false;
    public auth_type: boolean = true;
    public reviewing_antian: boolean = false;
    public new_add_flag: boolean = false;
    public isVivoer: boolean = false;

    public constructor() {
        this.init_agreement();
    }

    public static _getInstance(): SystemDataSys {
        if (!SystemDataSys._instance) {
            SystemDataSys._instance = new SystemDataSys();
        }
        return SystemDataSys._instance;
    }

    public init() {
        // let e = EngineUtil.getLocalData("yid");
        // PlayerDataSys.initUserId({ yid: e });

        // let t = SdkHelper.getClientInfo();
        // ClientData.init(t);
    }

    public init_config(e: any) {
        // let t = e.activate,
        //     a = (e.activate_cpm, e.is_encrypt),
        //     o = (e.all_item, e.field_conf, e.shelves_conf, e.new_user);
        // this.encrypt = a || 0;
        // this.new_user = o;
        // PeripheralSystemDataMgr.setFdStatus(true);
        // t && SdkHelper.reportData("activate");
    }

    public online_release;
    public get_request_url(): string {
        return this.online_release ? this.server_release_url : this.server_test_url;
    }

    public get_version_url(): string {
        return this.online_release ? this.version_release_url : this.version_test_url;
    }

    public getTongDunId(): string | null {
        // let e = SdkHelper.requestTDId();
        // return "not_init" !== e ? e : null;
        return ""
    }

    public update_user_url(e: string = "err_param", t: string = "") {
        this.user_url += "&" + e + "=" + t;
    }

    public update_privacy_url(e: string = "err_param", t: string = "") {
        this.privacy_url += "&" + e + "=" + t;
    }

    public initTxRule(e: boolean = false) {
        this.update_user_url("tx_rule", e ? "true" : "false");
    }

    public initExtractRule(e: string = "") {
        this.update_user_url("extract_rule", e.length > 0 ? "true" : "false");
    }

    public init_agreement() {
        // if (!cc.sys.isBrowser) {
        //     let t = !this.online_release;
        //     let map = new Map([['channel_name', SdkHelper.getChannelName()],
        //     ['version_name', SdkHelper.getVersionName()],
        //     ['version_code', SdkHelper.getVersionCode()],
        //     ['debug', t]]);
        //     map.forEach((value, key) => {
        //         this.update_privacy_url(key, value);
        //         this.update_user_url(key, value);
        //     });
        // }
    }

    public init_middle_config(e: any) {
        // let t = JSON.parse(e),
        //     a = (t.location_flag, t.vv_flag, t.forbid_screen),
        //     o = t.forbid_red_envelope,
        //     i = (t.sm_flag, t.td_flag, t.hs_flag, t.notice_content, t.per_dialog_delay, t.notice_delay, t.ck_flag, t.tly_flag, t.force_flag, t.tab_flag, t.ysdk_flag),
        //     r = (t.dir_flag, t.antian_flag),
        //     n = t.new_add_flag;
        // this.reviewing = void 0 === o || o;
        // this.reviewing_splash = void 0 !== a && a;
        // this.auth_type = void 0 !== i && i;
        // this.reviewing_antian = void 0 !== r && r;
        // this.new_add_flag = void 0 !== n && n;
        // for (let s = ["6a28cf34-87dc-329f-9861-1135e692b9fa", "d2bfaf49-d217-3411-9a7d-afce6179e0ac"], c = 0; c < s.length; c++)
        //     if (s[c] == ClientData.device_id) {
        //         this.isVivoer = true;
        //         break;
        //     }
        // cc.sys.isNative || (this.reviewing = false);
    }

    public is_new_user(): boolean {
        // return  this.new_user;
        return false;
    }

}

export default SystemDataSys._getInstance();